package com.dealer.management.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dealer.management.entity.Customer;
import com.dealer.management.mapper.CustomerMapper;
import com.dealer.management.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public IPage<Customer> getCustomerPage(Page<Customer> page, String name) {
        return customerMapper.selectCustomerPage(page, name);
    }

    @Override
    public Customer getCustomerById(Long id) {
        return customerMapper.selectById(id);
    }

    @Override
    public boolean saveCustomer(Customer customer) {
        return customerMapper.insert(customer) > 0;
    }

    @Override
    public boolean updateCustomer(Customer customer) {
        return customerMapper.updateById(customer) > 0;
    }

    @Override
    public boolean deleteCustomer(Long id) {
        return customerMapper.deleteById(id) > 0;
    }
}
